package TeachLesson;

import StudentLesson.StuCourseWorkDao;
import StudentLesson.StuCourseWorkEnity;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "updateScoreServlet")
public class updateScoreServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       int id=Integer.parseInt(request.getParameter("id"));
       String score=request.getParameter("score");
       StuCourseWorkDao stuCourseWorkDao=new StuCourseWorkDao();
       int row=stuCourseWorkDao.updateScore(id,score);
       StuCourseWorkEnity stuCourseWorkEnity=stuCourseWorkDao.getStuCouWor(id);
       if(row>0){
           response.sendRedirect("/Teachers/CorrectWork.jsp?score="+score+"&courseNo="+stuCourseWorkEnity.getCourseNo()+"&workerNo="+stuCourseWorkEnity.getWorkerNo()+"&id="+stuCourseWorkEnity.getCourseId());
       }else {
           response.getWriter().println("插入出错");
       }

    }
}
